package edu.ynu.se.xiecheng.achitectureclass.service.Impl;

import edu.ynu.se.xiecheng.achitectureclass.dao.CO2DataDao;
import edu.ynu.se.xiecheng.achitectureclass.dto.DataDTO;
import edu.ynu.se.xiecheng.achitectureclass.service.CO2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CO2ServiceImpl implements CO2Service {

    @Autowired
    private CO2DataDao co2DataDao;

    @Override
    public List<DataDTO> findLatestTenCO2Data() {
        // 创建一个PageRequest，限制返回的记录数为10条
        Pageable pageable = PageRequest.of(0, 10);  // 第一个参数是页码（从0开始），第二个参数是每页返回的记录数
        return co2DataDao.findLatestTenCO2Data(pageable);
    }
}
